﻿<ResourceDictionary 
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:local="clr-namespace:Jade.Tools.SL.Controls"
    xmlns:localLoading="clr-namespace:Jade.Tools.SL.Controls.LoadingControl">

    <Style TargetType="local:ImageButton">
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="FontFamily" Value="Calibri"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ImageButton">
                    <Grid x:Name="GridContainer" RenderTransformOrigin="0.5,0.5">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">

                                <VisualStateGroup.Transitions>
                                    <VisualTransition To="MouseOver"  GeneratedDuration="00:00:00.1"/>
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="Normal">
                                    <Storyboard >
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.15"/>
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.15"/>
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GridContainer"
                               Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="1.0" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.50" Value="1.15">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <ElasticEase EasingMode="EaseOut" Oscillations="2"/>
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GridContainer"
                               Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="1.0" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.50" Value="1.15">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <ElasticEase EasingMode="EaseOut" Oscillations="2"  />
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Image Source="{TemplateBinding Source}" Stretch="Fill" x:Name="img"/>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              x:Name="contentPresenter"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localLoading:BusyPointer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localLoading:BusyPointer">
                    <Grid x:Name="LayoutRoot" Background="Transparent">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="Busied">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="VisualElement" Storyboard.TargetProperty="(UIElement.RenderTransform).Angle" RepeatBehavior="Forever">
                                            <SplineDoubleKeyFrame KeyTime="0:0:1" Value="360" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Ellipse Width="25" Height="25" StrokeThickness="5.5" x:Name="VisualElement">
                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF096475" Offset="0.571"/>
                                    <GradientStop Color="#FFA8FCFC" Offset="1"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                            <Ellipse.RenderTransform>
                                <RotateTransform CenterX="12.5" CenterY="12.5" />
                            </Ellipse.RenderTransform>
                        </Ellipse>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="localLoading:ImageLoader">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="localLoading:ImageLoader">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="00:00:00" />
                                    <VisualTransition GeneratedDuration="00:00:00.3000000" To="Normal"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Loading">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ImageControl" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00.0000000" Duration="00:00:00.000000" 
                                                                       Storyboard.TargetName="LoadingControl" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Failed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00.4000000" Duration="00:00:00.0010000" 
                                                                       Storyboard.TargetName="FailedBorder" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Image x:Name="ImageControl" 
                               Stretch="Fill" />
                        <Viewbox Height="60" Width="60">
                            <localLoading:BusyPointer x:Name="LoadingControl"
                                           IsBusy="True"
                                           Visibility="Collapsed"/>
                        </Viewbox>
                        <sdk:Label x:Name="lbPercent" Content="0%" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red"  FontWeight="Bold"  FontSize="10"/>
                        <Border BorderThickness="3"
                                BorderBrush="#FFFF3333"
                                x:Name="FailedBorder"
                                Visibility="Collapsed"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


</ResourceDictionary>
